Warning: mkdir(): No space left on device in /var/www/tg-me/post.php on line 37

Warning: file_put_contents(aCache/aDaily/post/csharp_ci/--): Failed to open stream: No such file or directory in /var/www/tg-me/post.php on line 50
C# (C Sharp) programming | Telegram Webview: csharp_ci/1386 -
Telegram Group & Telegram Channel
🚀 HybridCache

Это решение давней проблемы с разделением между IMemoryCache и IDistributedCache.

🔧 Что даёт HybridCache:
• Единый API для in-memory и distributed кэша
• Настраиваемая сериализация
• Stampede protection (анти-нагрузочная защита)
• Удаление по тегам

🧠 Как работает GetOrCreateAsync:
1. Проверяет локальный и распределённый кэш
2. Если нет — вызывает фабричный метод
3. Кэширует результат и возвращает его

🛡️ Stampede protection: только один запрос на ключ запускает фабрику, остальные ждут — никакой гонки или перегрузки БД.

📌 Сниппет на .NET 9 выглядит так:


app.MapGet("/products/{id}", async (
int id,
HybridCache cache,
ProductDbContext db,
CancellationToken ct) =>
{
var product = await cache.GetOrCreateAsync(
$"product-{id}",
async token =>
{
return await db.Products
.Include(p => p.Category)
.FirstOrDefaultAsync(p => p.Id == id, token);
},
cancellationToken: ct
);

return product is null ? Results.NotFound() : Results.Ok(product);
});


HybridCache доступен для ASP.NET Core

Все разработчики могут воспользоваться HybridCache для более эффективного управления кэшем в приложениях на ASP.NET Core.



tg-me.com/csharp_ci/1386
Create:
Last Update:

🚀 HybridCache

Это решение давней проблемы с разделением между IMemoryCache и IDistributedCache.

🔧 Что даёт HybridCache:
• Единый API для in-memory и distributed кэша
• Настраиваемая сериализация
• Stampede protection (анти-нагрузочная защита)
• Удаление по тегам

🧠 Как работает GetOrCreateAsync:
1. Проверяет локальный и распределённый кэш
2. Если нет — вызывает фабричный метод
3. Кэширует результат и возвращает его

🛡️ Stampede protection: только один запрос на ключ запускает фабрику, остальные ждут — никакой гонки или перегрузки БД.

📌 Сниппет на .NET 9 выглядит так:


app.MapGet("/products/{id}", async (
int id,
HybridCache cache,
ProductDbContext db,
CancellationToken ct) =>
{
var product = await cache.GetOrCreateAsync(
$"product-{id}",
async token =>
{
return await db.Products
.Include(p => p.Category)
.FirstOrDefaultAsync(p => p.Id == id, token);
},
cancellationToken: ct
);

return product is null ? Results.NotFound() : Results.Ok(product);
});


HybridCache доступен для ASP.NET Core

Все разработчики могут воспользоваться HybridCache для более эффективного управления кэшем в приложениях на ASP.NET Core.

BY C# (C Sharp) programming




Share with your friend now:
tg-me.com/csharp_ci/1386

View MORE
Open in Telegram


C C Sharp programming Telegram | DID YOU KNOW?

Date: |

Importantly, that investor viewpoint is not new. It cycles in when conditions are right (and vice versa). It also brings the ineffective warnings of an overpriced market with it.Looking toward a good 2022 stock market, there is no apparent reason to expect these issues to change.

Can I mute a Telegram group?

In recent times, Telegram has gained a lot of popularity because of the controversy over WhatsApp’s new privacy policy. In January 2021, Telegram was the most downloaded app worldwide and crossed 500 million monthly active users. And with so many active users on the app, people might get messages in bulk from a group or a channel that can be a little irritating. So to get rid of the same, you can mute groups, chats, and channels on Telegram just like WhatsApp. You can mute notifications for one hour, eight hours, or two days, or you can disable notifications forever.

C C Sharp programming from us


Telegram C# (C Sharp) programming
FROM USA